Skip to content

Range mappings: test newline with non-zero original column - #46

Open
jessealama wants to merge 1 commit into
tc39:mainfrom
jessealama:range-mappings-newline-nonzero-column
Open

jessealama wants to merge 1 commit into
tc39:mainfrom
jessealama:range-mappings-newline-nonzero-column

Conversation

@jessealama

Copy link
Copy Markdown
Contributor

The rangeMappingsNewline test maps a range to original column 0, so it can't help us distinguish how the original column is computed for positions on later lines of a multi-line range. Add a test that starts the range at a non-zero original column.

The `rangeMappingsNewline` test maps a range to original
column 0, so it can't help us distinguish how the original
column is computed for positions on later lines of a
multi-line range. Add a test that starts the range at a
non-zero original column.
@jessealama

Copy link
Copy Markdown
Contributor Author

A question this test raises: when a generated position falls inside a range mapping, but on a later line than the one where the range starts, what should the original column be?

I can see three possibilities:

  1. The generated column, unchanged.
  2. The range's original column plus the generated column.
  3. The range's original column regardless of the generated column.

Our existing newline test is compatible with the first two, because its range starts at original column 0. The new test in this PR expects (1): a range mapping says the text is identical on both sides, and after a newline both sides restart at column 0, so the columns should line up directly.

I'm not sure that is the intended rule. It seems that the trace-mapping library currently implements (2). But if I understand the GetRangeMappedPosition spec text, we should get (3).

@nicolo-ribaudo

Copy link
Copy Markdown
Member

I'm pretty sure it should be (1).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants